function block = randomBitError_com(block, flag)
  //block.rpar(1) is BER
  //block.ipar(1) is number of bit per symbol
  if flag == 1 then 
    BER = block.rpar(1);
    bitNum = block.ipar(1);
    bits = de2bi(block.inptr(1), bitNum);  //convert symbol to bits
    bits = fixErrorRate(bits, BER); //insert err to bits
    block.outptr(1)(:) = bi2de(bits); //convert bits to symbols
  end
endfunction

